define(['common','jquery','vue'],function (common,$,Vue){
    const Controller = {
        index:function () {
            const {createApp,  ref, onMounted} = Vue
            const app = createApp({
                setup(){
                    const list = ref({
                        total:0,
                        rows:[],
                        page:1,
                        limit:10,
                        seachObj:[
                            {
                                label:'是否树状',
                                type:'select',
                                name:"isTree",
                                options:[
                                    {
                                        label:'是',
                                        value:1
                                    },
                                    {
                                        label:'否',
                                        value:0
                                    }
                                ],
                                value:1,
                                is_show:false
                            }
                        ]
                    })
                    const getIndexData = ()=>{
                        common.loadingIndexData(list.value).then(res=>{
                            if(res.code==1){
                                list.value.rows = res.data.rows
                                list.value.total = res.data.total
                            }
                        })
                    }
                    onMounted(()=>{
                        getIndexData()
                    })
                    const changePage = (page)=>{
                        list.value.page = page
                        getIndexData()
                    }
                    const changeSize = (size)=>{
                        list.value.limit = size
                        getIndexData()
                    }
                    const refresh = ()=>{
                        getIndexData()
                    }
                    common.refresh = refresh
                    // console.log(common,'-----------')
                    return {
                        list,
                        getTime:common.getTime,
                        getFilePath:common.getFilePath,
                        changePage,
                        changeSize,
                        refresh,
                        common,
                    }
                }
            })
            common.load(app)
            app.mount('#app')
        },
        edit:function () {
            const {createApp,  ref, onMounted} = Vue
            const app = createApp({
                setup(){
                    const form = ref(Config.row)
                    const allList = ref(Config.allList)
                    const allMenu = ref(Config.allMenu)
                    const props = {
                        label: 'title',
                        children: 'children',
                    }
                    const handleCheckChange = ()=>{

                    }
                    // console.log(common,'--------------')
                    return {
                        form,
                        sendSubmit:common.sendSubmit,
                        allList,
                        allMenu,
                        props,
                        handleCheckChange,
                        onEditSubmit:common.onEditSubmit,
                        common:common
                    }
                }
            })
            common.load(app)
            app.mount('#app')
        },
        add:function (){
            const {createApp,  ref, onMounted} = Vue
            const app = createApp({
                setup(){
                    const form = ref({
                        pid:0,
                        name:"",
                        rules:"",
                        status:1
                    })
                    const allList = ref(Config.allList)
                    const allMenu = ref(Config.allMenu)
                    const props = {
                        label: 'title',
                        children: 'children',
                    }
                    return {
                        form,
                        common:common,
                        allList,
                        allMenu,
                        props,
                    }
                }
            })
            common.load(app)
            app.mount('#app')
        }
    }
    return Controller
})